package com.ruoyi.travel.service.impl;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.travel.mapper.TravelClientMapper;
import com.ruoyi.travel.domain.TravelClient;
import com.ruoyi.travel.service.ITravelClientService;

@Service
public class TravelClientServiceImpl implements ITravelClientService
{
    @Autowired
    private TravelClientMapper travelClientMapper;

    /**
     * 查询客户管理
     *
     * @param clientId 客户管理主键
     * @return 客户管理
     */
    @Override
    public TravelClient selectTravelClientByClientId(Long clientId)
    {
        return travelClientMapper.selectTravelClientByClientId(clientId);
    }

    /**
     * 查询客户管理列表
     *
     * @param travelClient 客户管理
     * @return 客户管理
     */
    @Override
    public List<TravelClient> selectTravelClientList(TravelClient travelClient)
    {
//        travelClient.setOrderCount(travelClientMapper.selectOrderCount(travelClient.getClientId()));
//        travelClient.setScheduleCount(travelClientMapper.selectScheduleCount(travelClient.getClientId()));
//        System.out.println(travelClientMapper.selectOrderCount(travelClient.getClientId()));
//        System.out.println(travelClient);
        List<TravelClient> lists= travelClientMapper.selectTravelClientList(travelClient);
//        for(TravelClient tc:lists){
//            tc.setScheduleCount(travelClientMapper.selectScheduleCount(tc.getClientId()));
//            tc.setOrderCount(travelClientMapper.selectOrderCount(tc.getClientId()));
//        }
//        System.out.println(lists);
        return lists;
    }

    /**
     * 新增客户管理
     *
     * @param travelClient 客户管理
     * @return 结果
     */
    @Override
    public int insertTravelClient(TravelClient travelClient)
    {
        travelClient.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        travelClient.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
        travelClient.setCreateTime(DateUtils.getNowDate());
        return travelClientMapper.insertTravelClient(travelClient);
    }

    /**
     * 修改客户管理
     *
     * @param travelClient 客户管理
     * @return 结果
     */
    @Override
    public int updateTravelClient(TravelClient travelClient)
    {
        travelClient.setUpdateTime(DateUtils.getNowDate());
        travelClient.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
        return travelClientMapper.updateTravelClient(travelClient);
    }

    /**
     * 批量删除客户管理
     *
     * @param clientIds 需要删除的客户管理主键
     * @return 结果
     */
    @Override
    public int deleteTravelClientByClientIds(Long[] clientIds)
    {
        return travelClientMapper.deleteTravelClientByClientIds(clientIds);
    }

    /**
     * 删除客户管理信息
     *
     * @param clientId 客户管理主键
     * @return 结果
     */
    @Override
    public int deleteTravelClientByClientId(Long clientId)
    {
        return travelClientMapper.deleteTravelClientByClientId(clientId);
    }

    @Override
    public Long selectCountByTel(String clientTel) {
        return travelClientMapper.selectCountByTel(clientTel);
    }



}
